import java.util.Arrays;
public class Aufgabe1 {

    /**
     * 
     * @author Christian Pysk
     * Matr.Nr: 1828317
     *
     */
    
    public static int[][] transpose(int[][] matrix) {
        if (matrix.length == 0 || matrix[0].length == 0) {
            return new int[0][];
        }
        int[][] result = new int[matrix[0].length][];
        for(int i=0; i < result.length; i++) {
            result[i] = new int[matrix.length];
        }
        for(int i=0; i < matrix.length; i++) {
            for(int j=0; j < matrix[i].length; j++) {
                result[j][i] = matrix[i][j];
            }
        }
        return result;
    }
    
    public static void printMatrix(int[][] matrix) {
        for(int[] row : matrix) {
            System.out.println(Arrays.toString(row));
        }
    }
        
    public static void main(String[] args) {
        int[][] matrix = {{4,7,10,13},{5,8,11,14},{6,9,12,15}};
        System.out.println("Eingabe:");
        printMatrix(matrix);
        System.out.println("Ausgabe:");
        printMatrix(transpose(matrix));    
    }
}
